home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 2.iso / Utils / UNIX / UNZIP520 / WINGUI / SELDIR.C < prev    next >
C/C++ Source or Header  |  1996-01-09  |  3KB  |  109 lines

  1. #include <string.h>
  2. #include <io.h>
  3. #include <stdio.h>
  4.  
  5. #include "wingui\wizunzip.h"
  6. #include "wingui\helpids.h"
  7.  
  8.  
  9. BOOL WINAPI SelectDirProc(HWND hDlg, WORD wMessage, WPARAM wParam, LPARAM lParam)
  10. {
  11.     static OPENFILENAME __far *lpofn = 0;
  12.     static WORD wClose;
  13.  
  14.     switch (wMessage)
  15.     {
  16.     case WM_DESTROY:
  17.         if (lpofn && lpofn->lpstrFile && (wClose == IDOK))
  18.         {
  19.          DWORD dwResult;      /* result of Save As Default button query */
  20.  
  21.          /* get state of Save As Default checkbox, if appropriate */
  22.          if (!uf.fUnzipToZipDir)
  23.             {
  24.              dwResult = SendDlgItemMessage(hDlg , IDM_SAVE_AS_DEFAULT, BM_GETSTATE, 0, 0);
  25.              if (dwResult & 1)   /* if checked */
  26.                  {
  27.                  /* save as future default */
  28.                  WritePrivateProfileString(szAppName, szDefaultUnzipToDir,
  29.                                 lpofn->lpstrFile, szWizUnzipIniFile);
  30.  
  31.                  }
  32.             }
  33.         }
  34.         break;
  35.     case WM_COMMAND:
  36.         /* When the user presses the OK button, stick text
  37.            into the filename edit ctrl to fool the commdlg
  38.            into thinking a file has been chosen.
  39.            We're just interested in the path, so any file
  40.            name will do - so long as it doesn't match
  41.            a directory name, we're fine
  42.         */
  43.  
  44.         if (LOWORD(wParam) == IDOK)
  45.         {
  46.             SetDlgItemText(hDlg, edt1, "johnny\376\376.\375\374\373");
  47.             wClose = LOWORD(wParam);
  48.         }
  49.         else if (LOWORD(wParam) == IDCANCEL)
  50.         {
  51.             wClose = LOWORD(wParam);
  52.         }
  53.         break;
  54.     case WM_INITDIALOG:
  55.         {
  56.             RECT    rT1, rT2;
  57.             short   nWidth, nHeight;
  58.  
  59. #ifndef WIN32
  60.             lpofn = (OPENFILENAME __far *)lParam;
  61. #else
  62.             lpofn = (OPENFILENAME *)lParam;
  63. #endif
  64.             CenterDialog(GetParent(hDlg), hDlg); /* center on parent */
  65.  
  66.             wClose = 0;
  67.  
  68.             /* Disable and hide the "save as default" checkbox */
  69.             EnableWindow(GetDlgItem(hDlg, IDM_SAVE_AS_DEFAULT), FALSE);
  70.             ShowWindow(GetDlgItem(hDlg, IDM_SAVE_AS_DEFAULT), SW_HIDE);
  71.  
  72.             /* Disable the filename edit ctrl
  73.                and the file type label
  74.                and the file type combo box
  75.                Note: stc2, cmb1 etc are defined in DLGS.H in the standard
  76.                windows include files.
  77.             */
  78.             EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
  79.             EnableWindow(GetDlgItem(hDlg, stc2), FALSE);
  80.             EnableWindow(GetDlgItem(hDlg, cmb1), FALSE);
  81.  
  82.             GetWindowRect(GetDlgItem(hDlg, cmb2), &rT1);
  83.  
  84.             /*  Hide the file type label & combo box */
  85.             ShowWindow(GetDlgItem(hDlg, stc2), SW_HIDE);
  86.             ShowWindow(GetDlgItem(hDlg, cmb1), SW_HIDE);
  87.  
  88.             /* Extend the rectangle of the list of files
  89.                in the current directory so that it's flush
  90.                with the bottom of the Drives combo box
  91.             */
  92.             GetWindowRect(GetDlgItem(hDlg, lst1), &rT2);
  93.             nWidth = (short)(rT2.right - rT2.left);
  94.             nHeight = (short)(rT1.bottom - rT2.top);
  95.             ScreenToClient(hDlg, (LPPOINT)&rT2);
  96.             MoveWindow(GetDlgItem(hDlg, lst1),
  97.                         rT2.left, rT2.top,
  98.                         nWidth,
  99.                         nHeight,
  100.                         TRUE);
  101.         }
  102.     default:
  103.         break;
  104.     }
  105.  
  106.     /* message not handled */
  107.     return 0;
  108. }
  109.